<template>
	<view class="container">
		<topView></topView>
		<view class="main-container">
			<view class="progress-container">
				<view class="select-level">1</view>
				<view class="select-text">{{$t('language.jindu1')}}</view>
				<view class="divider-select"></view>
				<view class="select-level">2</view>
				<view class="select-text">{{$t('language.jindu2')}}</view>
				<view class="divider-select"></view>
				<view class="select-level">3</view>
				<view class="select-text">{{$t('language.jindu3')}}</view>
			</view>
			<image class="success-image" src="../../static/icon_success_buy.png"></image>
			<view v-if="carmyList.length>0">
				<view class="success-text">{{$t('language.buySuccess')}}</view>
				<view class="tips-container">
					<view class="tips-gray">{{$t('language.chongzhi')}}</view>
					<view class="tips-blue">{{currOrder.price}}{{$t('language.yuan')}}</view>
					<view class="tips-gray">{{$t('language.keduihuan')}}</view>
					<image class="number-image" :src="$imgUrl+currOrder.sort_img"></image>
					<view class="tips-blue">x{{currOrder.gold_sum}}x{{currOrder.sum}}</view>
				</view>
				<view class="copy-container">
					<view v-for="(item,i) in carmyList" :key="i" class="copy-item">
						<view class="code">{{item.carmy}}</view>
						<view class="divider-line"></view>
						<view class="copy-text" @click.stop="copySuccess(item.carmy)">{{$t('language.fuzhi')}}</view>
					</view>
				</view>
			</view>
			<view  v-else>
				<view class="buy-success-text">{{$t('language.wujilu')}}</view>
			</view>
		</view>
		<view class="copy-right-container">Copyright 2020 {{$t('language.mayi')}}</view>
	</view>
</template>

<script>
import topView from '@/components/topView/topView.vue'
export default {
		data() {
			return {
				carmyList:[],
				currOrder:{},
				count:0.00,
				sum:0,
				num:0
			}
		},
		async onLoad(options) {
			if(options.orderNo){
				this.getCarmy(options.orderNo)
			}else{
				this.count=options.count;
				this.sum=options.sum;
				this.num=options.num;
			}
		},
		methods: {
			getCarmy(order_code){
				this.$http.post('order.getCarmy', {
					order_code:order_code,
				lang:window.sessionStorage.getItem('lang') || 'cn'}).then(res => {
					console.log("res",res.data)
					this.carmyList=res.data.cary
					this.currOrder=res.data
				}).catch(e => {
				})
			},
			copySuccess(context){
				// 创建输入框元素
				let oInput = document.createElement('input');
				// 将想要复制的值
				oInput.value = context;
				// 页面底部追加输入框
				document.body.appendChild(oInput);
				// 选中输入框
				oInput.select();
				// 执行浏览器复制命令
				document.execCommand('Copy');
				// 弹出复制成功信息
				uni.showToast({
					title: '复制成功',
					icon: 'none'
				})
				// 复制后移除输入框
				oInput.remove();
			}
		}
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		background: #F0F2F5;
	}
	.container {
		display: flex;
		flex-direction: column;
	}
	.main-container {
		width: 1820rpx;
		min-height: 1176rpx;
		background: #FFFFFF;
		border-radius: 4rpx;
		margin:80rpx auto 0;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.progress-container {
		display: flex;
		flex-direction: row;
		align-items: center;
		width: 1416rpx;
		margin-top: 80rpx;
	}
	.select-level {
		width: 64rpx;
		height: 64rpx;
		background: linear-gradient(360deg, #4185FF 0%, #73B1FF 100%);
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		font-family: HelveticaNeue;
		color: #FFFFFF;
		border-radius: 50%;
	}
	.unselect-level {
		width: 64rpx;
		height: 64rpx;
		border: 2rpx solid rgba(0,0,0,0.1500);
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		font-family: HelveticaNeue;
		color: rgba(0,0,0,0.1500);
		border-radius: 50%;
	}
	.divider-select {
		width: 280rpx;
		height: 2rpx;
		background: #4185FF;
		margin-left: 32rpx;
		margin-right: 32rpx;
	}
	.divider-unselect {
		width: 280rpx;
		height: 2rpx;
		background: rgba(0,0,0,0.1500);
		margin-left: 32rpx;
		margin-right: 32rpx;
	}
	.select-text {
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0,0,0,0.6500);
		margin-left: 16rpx;
	}
	.unselect-text {
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0,0,0,0.1500);
		margin-left: 16rpx;
	}
	.success-image {
		margin-top: 154rpx;
		width: 526rpx;
		height: 360rpx;
	}
	.success-text {
		font-size: 48rpx;
		margin-top: 48rpx;
		width: 100%;
		text-align: center;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(0,0,0,0.8500);
	}
	.tips-container {
		display: flex;
		flex-direction: row;
		margin-top: 16rpx;
		align-items: center;
	}
	.tips-gray {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0,0,0,0.4300);
	}
	.tips-blue {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #4185FF;
	}
	.number-image {
		width: 32rpx;
		height: 24rpx;
	}
	.copy-container {
		width: 758rpx;
		background: rgba(245,245,245,0.5000);
		border-radius: 4rpx;
		border: 1rpx solid #D1D2D5;
		margin-top: 64rpx;
	}
	.copy-item{
		display: flex;
		align-items: center;
		justify-content: center;
		height: 80rpx;
	}
	.code {
		font-size: 48rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0,0,0,0.8000);
	}
	
	.copy-text {
		font-size: 48rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #4185FF;
	}
	
	.divider-line {
		width: 1rpx;
		height: 30rpx;
		background: #cccccc;
		margin-left: 30rpx;
		margin-right: 30rpx;
	}
	.copy-right-container {
		width: 100%;
		height: 136rpx;
		text-align: center;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0,0,0,0.4500);
		padding-top: 48rpx;
	}
</style>